package com.neusoft.tijian.controller;

import java.util.List;

import com.neusoft.tijian.aop.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.tijian.po.Orders;
import com.neusoft.tijian.service.OrdersService;

/**
 * 订单
 */
@RestController
@RequestMapping("/orders")
public class OrdersController {
	
	@Autowired
	private OrdersService ordersService;

	/**
	 * 查询是否是已预约状态，已预约不可再次预约
	 * @param orders
	 * @return
	 */
	@RequestMapping("/getOrdersByUserId")
	public int getOrdersByUserId(@RequestBody Orders orders) {
		return ordersService.getOrdersByUserId(orders.getUserId());
	}

	/**
	 * 保存订单，预约支付成功。
	 * @param orders
	 * @return
	 */
	@Log
	@RequestMapping("/saveOrders")
	public int saveOrders(@RequestBody Orders orders) {
		return ordersService.saveOrders(orders);
	}

	/**
	 * 查看订单信息
	 * @param orders
	 * @return
	 */
	@RequestMapping("/listOrdersByUserId")
	public List<Orders> listOrdersByUserId(@RequestBody Orders orders) {
		return ordersService.listOrdersByUserId(orders);
	}

	/**
	 * 取消预约
	 * @param orders
	 * @return
	 */
	@Log
	@RequestMapping("/removeOrders")
	public int removeOrders(@RequestBody Orders orders) {
		return ordersService.removeOrders(orders.getOrderId());
	}
	
	@RequestMapping("/getOrdersById")
	public Orders getOrdersById(@RequestBody Orders orders) {
		return ordersService.getOrdersById(orders.getOrderId());
	}
}
